﻿using System;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using Ue.Infrastructure.RepositoryFramework;
using Ue.Infrastructure.Web.UI;
using Ue.Qcdz.Domain.Medias;

namespace Ue.Qcdz.UI.Controls
{
    public class MediaItem : SkinnedGridView
    {
        private string skinFileName = "~/Themes/zh-cn/Skins/Medias/MediaItem.ascx";
        private IMediaRepository repostiory;
        public string TypeId { get; set; }

        #region Overrides of SkinnedControl
        public MediaItem()
        {
            repostiory = RepositoryFactory.GetRepository<IMediaRepository, TheMedia>();
        }

        protected override string GetSkinFileName()
        {
            return skinFileName;
        }

        #endregion

        #region Overrides of SkinnedGridView

        protected override void GridViewDataBind(object sender, EventArgs args)
        {
            IList<TheMedia> theMediaes = repostiory.FindBy(TypeId);
            Repeater repeater = sender as Repeater;
            repeater.DataSource = theMediaes;
            repeater.DataBind();
        }

        #endregion
    }
}
